package com.zxy

import java.net.URI
import java.text.SimpleDateFormat
import java.util.Date

import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileSystem, Path}

/**
 * @ObjectName Utility
 * @Description TODO
 * @Author zhuxianyu
 * @Date 2021/11/29 16:37
 * @Version 1.0
 */
object Utility {

  def getDay(dt: String, num: Int) = {
    val format = new SimpleDateFormat("yyyy-MM-dd")
    val daySpan = 3600L * 24 * 1000 // 一天的毫秒
    format.format(new Date(format.parse(dt).getTime + num * daySpan))
  }

  def hdfsPathExits(path: String) = {
    val fs = FileSystem.get(new URI("/tmp"), new Configuration())
    fs.exists(new Path(path))
  }

}
